<?php
class RegisterController extends Nguyen_Controller_Action{
	public function init(){
		$this->loadTemplate('default');
	}
	public function testAction(){
		$this->_helper->layout()->disableLayout(); 
        $this->_helper->viewRenderer->setNoRender(true);
        $model = new Administrator_Model_User();
        echo $model->GetCheckUsername('than90');
	}
	public function indexAction(){
		$model = new Administrator_Model_User();
		$username = $this->_request->getParam('username','');
		$password = $this->_request->getParam('password','');
		$password1 = $this->_request->getParam('password1','');
		$name = $this->_request->getParam('name','');
		$email = $this->_request->getParam('email','');
		$gender= $this->_request->getParam('gender','');
		$address = $this->_request->getParam('address','');
		$phone = $this->_request->getParam('phone','');
		$birthday = $this->_request->getParam('birthday','');

	if ($this->_request->isPost ()) {
			if ($this->_request->getParam ( 'nhan' )) {
				if(($username =='')||($model->GetCheckUsername($username) == 1)){
					echo 'Username đã tồn tại hay chưa nhập';
				}
				else{
					if($password==''){
						echo 'Yêu cầu nhập password';
					}else {
						if($password != $password1){
							echo 'Yêu cầu xác nhận lại password';
						}else {
					
							$model->InsertUserAll($username,md5($password) , '', $name, $birthday, $gender, $address, $email, '4', '1', $phone);
						}
					}
					
				}
			}
			
		}
		
	}
}